Release 10.1A: OpenEdge Development:
Progress Dynamics Web Development Guide


Extending existing JavaScript object types

You can customize the Progress Dynamics DHTML framework by extending objects with your own JavaScript code. You can do this by configuring existing objects to use alternative code for object instantiation. To do this, you must know JavaScript fairly well and must be able to read the current code.

You might also have future compatibility issues if the APIs change. Generally, extending existing objects is safer than replacing them. Also, since ADM objects expect a certain API, the best method for extending JavaScript object types is to make modifications based on an existing object type.

For example, consider the Browse object that is defined in rybrowse.js.

To extend the Browse object:

  1. Create a new file (for example, mybrowse.js) in the install_dir/tty/dynamics/dhtml/ directory. The default rybrowse.js is also found in install_dir/tty/dynamics/dhtml/.
  2. Include your file by adding a SCRIPT element to your default HTML file. For example:
  3. <script language="javascript" src="mybrowse.js"></script> 
    

  4. Define an object prototype that is similar to the object defined in rybrowse.js.
  5. The object prototype name must have the first letter uppercase and the rest in lowercase. See Browse2 in the following example:

    // mybrowse.js
    // Sample of syntax for overriding current Browse code with new 
    functionality
    
    Browse2.prototype=new Browse();  //To override/extend the current Browse
    Browse2.prototype.instance_myvar=value;  //Add your own variables
    
    function Browse2(){  //Code executes when created, but after Browse()
    {initialization code…}
    }
    
    Browse2.prototype.myfunc=function(){  // Add your own methods
    {my code…}
    } 
    

  6. Specify your object prototype name as a JavaScriptObject attribute for the application object.
  7. The JavaScriptObject attribute is one of the attributes that you can set in the Dynamic Properties dialog box. For example, the following figure shows a setting that causes Browse to be overridden by Browse2 in the customerfullb application object:

    When the application handler object initiates customerfullb, it will see the Browse2 object type and initiate it with the Browse2 prototype.


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095